<template>
    <div v-if="article" class="article-detail">
      <h1>{{ article.title }}</h1>
      <div class="meta">
        <span>{{ article.author }}</span>
        <span>{{ article.date }}</span>
      </div>
      <div class="content">{{ article.content }}</div>
      <router-link to="/">返回列表</router-link>
    </div>
  </template>
  
  <script>
  export default {
    props: ['id'],
    computed: {
      article() {
        return this.$store.state.articles.find(a => a.id === Number(this.id))
      }
    }
  }
  </script>